import time
import unittest
from autoframe.common.functions import open_browser
from autoframe.page.generate_order_page import OrderLocation
from autoframe.page.login_page import LoginPage
from autoframe.page.index_page import IndexPage


class AddressManagementTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        # 打开浏览器
        driver = open_browser()
        cls.order = OrderLocation(driver)
        cls.login = LoginPage(driver)
        cls.index = IndexPage(driver)

    def test_order_1(self):  # 支付流程  炫彩翻页保护套-邮政平邮-余额支付
        self.order.generate_order_login()
        self.order.generate_order_01()
        # 断言
        information = self.order.H6_text()  # 获取支付后的订单号
        generate = self.order.list_text()  # 获取我的订单管理里面的订单号
        self.assertEqual(generate, information, msg='修改地址失败')

    def test_order_2(self):  # 支付流程  炫彩翻页保护套-邮政平邮-银行卡额支付
        self.order.generate_order_02()
        # 断言
        information = self.order.H6_text()  # 获取支付后的订单号
        generate = self.order.list_text()  # 获取我的订单管理里面的订单号
        self.assertEqual(generate, information, msg='修改地址失败')

    def tearDown(self) -> None:
        # 返回首页
        self.index.return_home()

    @classmethod
    def tearDownClass(cls) -> None:
        # 退出浏览器
        cls.login.quit()


if __name__ == '__main__':
    unittest.main(verbosity=2)
